package cheqex.dao;

import org.apache.torque.util.Criteria;
import java.util.Date;

import java.util.ArrayList;
import java.util.List;
/*
Collection Cash Peer:
addCollectionCash - adds deposit cash data
editCollectionCash - edit deposit cash data 
deleteCollectionCash -  delete deposit cash data
*/
public class CollectionCashPeer extends cheqex.dao.BaseCollectionCashPeer
{
	public static boolean addCollectionCash(String orNumber, int amt, String particulars, java.sql.Date orDate, int id){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		criteria.add(CollectionCashPeer.AMOUNT, amt);
		criteria.add(CollectionCashPeer.PARTICULARS, particulars);
		criteria.add(CollectionCashPeer.ORDATE, orDate);
		criteria.add(CollectionCashPeer.WEEKID, id);
		try{
			CollectionCashPeer.doInsert(criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static List<CollectionCash> retrieveAllCollectionCash(java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORDATE,date);
		
		try{
			return (List<CollectionCash>)CollectionCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCash>();
		}
	}
	
	public static List<CollectionCash> retrieveWeekCollectionCash(int id){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.WEEKID,id);
		
		try{
			return (List<CollectionCash>)CollectionCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCash>();
		}
	}
	
	public static boolean editCollectionCash(String orNumber, int amt, String particulars, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.AMOUNT, amt);
		criteria.add(CollectionCashPeer.PARTICULARS, particulars);
		
		
		Criteria scriteria = new Criteria();
		scriteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		scriteria.add(CollectionCashPeer.ORDATE, date);
		try{
			CollectionCashPeer.doUpdate(scriteria, criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static boolean deleteCollectionCash(String orNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		criteria.add(CollectionCashPeer.ORDATE, date);
		try{
			CollectionCashPeer.doDelete(criteria);
			return true;
		}catch (Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public static CollectionCash getOR(String orNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		criteria.add(CollectionCashPeer.ORDATE, date);
		try{
			if((CollectionCash)CollectionCashPeer.doSelect(criteria).get(0)!=null)
				return (CollectionCash)CollectionCashPeer.doSelect(criteria).get(0);
			else return null;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}

	public static List<CollectionCash> getData(String orNumber){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		
		try{
			return (List<CollectionCash>)CollectionCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	public static List<CollectionCash> filterCollectionCashByORNo(String orNumber){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		
		try{
			return (List<CollectionCash>)CollectionCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCash>();
		}
	}
	
	public static List<CollectionCash> filterCollectionCashByORDate(java.sql.Date orDate){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORDATE, orDate);
		
		try{
			return (List<CollectionCash>)CollectionCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCash>();
		}
	}
	
	public static List<CollectionCash> searchCollectionCashParticular(String orNumber, java.util.Date orDate){
		Criteria criteria = new Criteria();
		criteria.add(CollectionCashPeer.ORNUMBER, orNumber);
		criteria.add(CollectionCashPeer.ORDATE, orDate);
		
		try{
			return (List<CollectionCash>)CollectionCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<CollectionCash>();
		}
	}
}
